# BEGIN TOMBOLA_ABC

import abc
import sys


class Tombola(abc.ABC):  # <1>
    """基类 abc._get_dump(Tombola)
    (_abc_registry, _abc_cache, _abc_negative_cache, _abc_negative_cache_version)
    >>> @Tombola.register class TombolaVirtual():pass
    >>> abc._get_dump(Tombola)
    >>> virtual_subclasses = [ref() for ref in abc._get_dump(Tombola)[0] if ref()]
    >>> virtual_subclasses
    >>> Tombola._abc_registry if hasattr(Tombola, '_abc_registry') else sys.version

    """

    @abc.abstractmethod
    def load(self, iterable):  # <2>
        """Add items from an iterable."""

    @abc.abstractmethod
    def pick(self):  # <3>
        """Remove item at random, returning it.

        This method should raise `LookupError` when the instance is empty.
        """

    def loaded(self):  # <4>
        """Return `True` if there's at least 1 item, `False` otherwise."""
        return bool(self.inspect())  # <5>

    def inspect(self):
        """Return a sorted tuple with the items currently inside."""
        items = []
        while True:  # <6>
            try:
                items.append(self.pick())
            except LookupError:
                break
        self.load(items)  # <7>
        return tuple(sorted(items))


# END TOMBOLA_ABC
if __name__ == "__main__":
    import doctest

    print("tombola 测试开始")
    (ff, tt) = doctest.testmod()
    print("测试结束:统计-失败{},总计{}".format(ff, tt))
    print("√" * tt if tt > 0 and not ff else "无测试" if not ff else "×" * ff)
